// JavaScript Document

function fullBg(obj){	/*ct-top img 背景全屏*/
	var winWidth, winHeight;
	if (window.innerWidth)
		winWidth = window.innerWidth;
	else if ((document.body) && (document.body.clientWidth))
		winWidth = document.body.clientWidth;
	// 获取窗口高度
	if (window.innerHeight)
		winHeight = window.innerHeight;
	else if ((document.body) && (document.body.clientHeight))
		winHeight = document.body.clientHeight;
	// 通过深入 Document 内部对 body 进行检测，获取窗口大小
	if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
	{
		winHeight = document.documentElement.clientHeight;
		winWidth = document.documentElement.clientWidth;
	}
	obj.width(winWidth)
}

$(window).load(function(){
	fullBg($(".bannerbg"));
	var _h1 = $(".bannerbg").height();
	var _h2 = $(".banner").height();
	$(".bannerbg").css("marginTop",(_h2-_h1)/2+"px")
	
	/*Start img 宽度比例*/
	var img = $(".userImgContent").find("img");
	img.each(function(i, o) {
		var _w = this.width;
		var _h = this.height;
		var W = 0, H = 0;
		if(_w>=_h&&_h>90){
			H = 90;
			W = H*_w/_h;
			this.style.marginLeft = (H-W)/2 + "px";
		}
		else if(_h>_w&&_w>90){
			W = 90;
			H = W*_h/_w;
			this.style.marginTop = (W-H)/2 + "px";
		}
		else if(_h<90||_W<90){
			H = _h;
			W = _w;
			this.style.marginTop = (90-H)/2 + "px";
			this.style.marginLeft = (90-W)/2 + "px";
		}
		this.style.width = W + "px";
		this.style.height = H + "px";
	});
})
$(window).resize(function(){
	fullBg($("bannerbg"));
	var _h1 = $(".bannerbg").height();
	var _h2 = $(".banner").height();
	$(".bannerbg").css("marginTop",(_h2-_h1)/2+"px")
})	//End ct-top 背景全屏